<template>
  <div id="app">
    <h1>vue2-signature</h1>
    <div class="btns">
      <button class="btn" v-for="(name,index) in nameList" 
      :key="index" :class="{active:index===active}" @click="toggle(index)">{{ name }}</button>
    </div>
    <div class="sign">
      <signature1 v-if="active===0" />
      <signature2 v-else/>

    </div>
  </div>
</template>

<script>
import signature1 from '@/components/signature1.vue'
import signature2 from '@/components/signature2.vue'

export default {
  name: 'App',
  components: {
    signature1,
    signature2,
  },
  data(){
    return {
      nameList: ['手写签名','vue-esign 插件签名'],
      active:0
    }
  },
  mounted(){
   
  },
  methods:{
    toggle(val){
      this.active = val
    }
    
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
h1{
  position:absolute;
  top:50px;
  left:50%;
  transform:translate(-50%,-150%);
}
.btns{
  position:absolute;
  top:50px;
  left:50%;
  transform:translate(-50%,30%);
  cursor: pointer;
}
.btn{
  background: rgb(170, 170, 237);
  color:white;
  border:none;
  padding:10px 20px;
  cursor: pointer;
}
.active{
  background: rgb(78, 78, 162);
}
.sign{
  margin-top:100px;
}
</style>
